package cn.lingyangwl.agile.pay.mch.controller;

import cn.lingyangwl.framework.core.response.Resp;
import cn.lingyangwl.agile.pay.model.rqrs.BillDownloadQueryReq;
import cn.lingyangwl.agile.pay.model.rqrs.BillDownloadRS;
import cn.lingyangwl.agile.pay.common.service.BillService;
import cn.lingyangwl.agile.ram.ActionType;
import cn.lingyangwl.agile.ram.RamResource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author shenguangyang
 */
@Slf4j
@ApiModel("账单下载")
@RestController("mchBillDownloadController")
@RequestMapping("/bill")
public class BillDownloadController {
    @Resource
    private BillService billService;

    /**
     * 分页 账单下载
     */
    @GetMapping("/page")
    @RamResource(action = "pay:bill:list", name = "查询账单下载列表", type = ActionType.READ)
    public Resp<IPage<BillDownloadRS>> page(@Validated BillDownloadQueryReq req) {
        return Resp.ok(billService.pageBillDownload(req));
    }

    /**
     * 通过id查找 账单下载
     */
    @GetMapping("/getById")
    @RamResource(action = "pay:bill:get", name = "查询账单下载详情", type = ActionType.READ)
    public Resp<BillDownloadRS> getById(@RequestParam(value = "id") Long id) {
        return Resp.ok(billService.getBillDownload(id));
    }

    /**
     * 批量删除 账单下载
     */
    @DeleteMapping("/deleteBatch")
    @RamResource(action = "pay:bill:delete", name = "删除转账订单", type = ActionType.WRITE)
    public Resp<?> deleteBatch(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(billService.batchDeleteBillDownload(ids));
    }

    /**
     * 删除 账单下载
     */
    @DeleteMapping("/deleteById")
    @RamResource(action = "pay:bill:delete", name = "删除转账订单", type = ActionType.WRITE)
    public Resp<?> delete(@RequestParam(value = "id") Long id) {
        return Resp.ok(billService.deleteBillDownload(id));
    }
}
